Take home account from request, if not available elsewhere.#6064
Closed
bgavrilMS wants to merge 3 commits into
Closed
Take home account from request, if not available elsewhere.#6064bgavrilMS wants to merge 3 commits into
bgavrilMS wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a token refresh scenario for non-Azure OIDC providers (e.g., PingIdentity) where refresh token responses can omit both client_info and id_token, previously leading to an inability to derive a home_account_id for caching. The change adds a safe fallback to use the home_account_id from the original request’s account when the response doesn’t provide enough information, and adds a unit test covering this behavior.
Changes:
- Update
TokenResponseHelper.GetHomeAccountIdto fall back torequestParams.Account.HomeAccountId.Identifierwhen bothclient_infoandid_tokensubject are unavailable. - Add a
TokenCacheTestsunit test validating token cache save behavior when refresh responses have neitherclient_infonorid_token.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/Microsoft.Identity.Test.Unit/CacheTests/TokenCacheTests.cs | Adds coverage for saving refreshed tokens when the token response lacks client_info and id_token. |
| src/client/Microsoft.Identity.Client/TokenResponseHelper.cs | Adds fallback logic to derive home_account_id from the request account when response fields are missing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI evaluation for fork PR #5657 (by @yowl). Fork PRs don't trigger CI pipelines, so re-creating here to validate.
Original PR: #5657
Fixes #5618
Changes proposed in this request
When refreshing a token, PingIdentity does not return the home account. This change takes the home account from the request if existing places do not supply it.
Testing
Added a test for the TokenCache for the PingIdentity scenario.